home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
PASCAL
/
0921.ZIP
/
JOYSTK.ARC
/
JOYDEMO1.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1987-03-30
|
3KB
|
82 lines
program JoyDemo1;
{
Author: David Howorth
Last updated: March 29, 1987
Application: A demonstration of procedure ReadJoy, a procedure for
reading the joystick (using variable parameters) and of
the functions ButtonA1, etc., which read the 4 joystick
buttons. Outputs raw data to the screen.
}
{$C-}
{ Above compiler directive necessary so that 'keypressed' function works
properly. Also speeds up screen output. }
var
ch : char;
Done : boolean;
JoyAX, { Note that these need not be }
JoyAY, { global variables; they could }
JoyBX, { be local to whatever procedure }
JoyBY : integer; { calls ReadJoy. }
{$I BUTTONS.INC}
{$I READJOY.INC}
begin
clrscr;
Done := false;
while keypressed do read(kbd,ch); { empty keyboard buffer }
writeln(' JOYSTICK DEMONSTRATION NUMBER 1');
writeln;
writeln(' (Joystick input shown as raw data)');
gotoxy(1,7);
writeln(' JOYSTICK A JOYSTICK B');
writeln(' X-Axis Y-Axis Button 1 Button 2 X-Axis Y-Axis Button 1 Button 2');
gotoxy(1,23);
writeln(' Press ''Q'' to quit.');
repeat
ReadJoy(JoyAX,JoyAY,JoyBX,JoyBY);
gotoxy(1,9);
if JoyAX >= 100
then write(' ',JoyAX)
else if JoyAX >=10
then write(' ',JoyAX)
else write(' ',JoyAX);
if JoyAY >= 100
then write(' ',JoyAY)
else if JoyAY >=10
then write(' ',JoyAY)
else write(' ',JoyAY);
if ButtonA1
then write(' IN')
else write(' OUT');
if ButtonA2
then write(' IN')
else write(' OUT');
write(' ');
if JoyBX >= 100
then write(' ',JoyBX)
else if JoyBX >=10
then write(' ',JoyBX)
else write(' ',JoyBX);
if JoyBY >= 100
then write(' ',JoyBY)
else if JoyBY >=10
then write(' ',JoyBY)
else write(' ',JoyBY);
if ButtonB1
then write(' IN')
else write(' OUT');
if ButtonB2
then write(' IN')
else write(' OUT');
if keypressed
then begin
read(kbd,ch);
if upcase(ch) = 'Q' then Done := true;
end;
until Done;
clrscr;
end.